package www.bplead.com.controller.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wangyangzi on 2016/9/5.
 */
public class StringUtil {
    public static boolean isEmpty(String str){
        if(str == null || str.equals("")){
            return true;
        }
        return false;
    }

    public static String makeGetURL(String requestURL, HashMap<String,String> paramsMap){
        String suffix = "";
        if(paramsMap.size() > 0){
            suffix = "?";
        }
        for(Map.Entry<String,String> entry : paramsMap.entrySet()){
            suffix += entry.getKey() + "=" + entry.getValue() + "&";
        }
        if(paramsMap.size() > 0){
            suffix = suffix.substring(0,suffix.length()-1);
        }
        return requestURL + suffix;
    }

    public static Gson getGson(){
        return new GsonBuilder().disableHtmlEscaping().create();
    }
}
